package com.itheima.mall.service.smsService;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.pojo.sms.SmsCouponProductRelation;
import com.itheima.mall.mapper.smsMapper.SmsCouponProductRelationMapper;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@DubboService
public class SmsCouponProductRelationImpl
        extends ServiceImpl<SmsCouponProductRelationMapper, SmsCouponProductRelation>
        implements SmsCouponProductRelationApi {
    @Autowired
    private SmsCouponProductRelationMapper smsCouponProductRelationMapper;
    @Override
    public void createCoupon(SmsCouponProductRelation smsCouponProductRelation) {
        smsCouponProductRelationMapper.insert(smsCouponProductRelation);
    }

    @Override
    public void updateWithId(SmsCouponProductRelation couponProductRelation) {
        smsCouponProductRelationMapper.updateById(couponProductRelation);
    }

    //获取单个优惠卷的详细信息
    @Override
    public List<SmsCouponProductRelation> getByCoupon(Long id) {
        LambdaQueryWrapper<SmsCouponProductRelation> wrapper = new LambdaQueryWrapper();
        wrapper.eq(SmsCouponProductRelation::getCouponId,id);
        List<SmsCouponProductRelation> list = smsCouponProductRelationMapper.selectList(wrapper);
        return list;
    }
}
